<?php
/*
 *   This file is part of poat.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 */
 
class language {

	var $id;

	public function __construct()
   {
   }

	// THIS CREATE A NEW INSTANCE OF THIS CLASS
	public function newInstance() {
		return new language;
	}

	public function delete() {
		$sql = "DELETE FROM ".LANGUAGE." WHERE id = ".util::str($this->id);
		return $sql;
	}
	
	public function listAll() {
		$sql = "SELECT * FROM ".LANGUAGE." ORDER BY id";
		return $sql;
	}

	public function listUnused() {
		$sql = "SELECT * FROM ".LANGUAGE." l WHERE NOT EXISTS (SELECT t.lang FROM ".TEAMS." t WHERE t.lang = l.id) ORDER BY id";
		return $sql;
	}

	public function listUsed() {
		$sql = "SELECT * FROM ".LANGUAGE." l WHERE EXISTS (SELECT t.lang FROM ".TEAMS." t WHERE t.lang = l.id) ORDER BY id";
		return $sql;
	}
		
	public function insert() {
		$sql = "INSERT INTO ".LANGUAGE;
		$sql .= " VALUES (".util::str($this->id).")";
		return $sql;
	}

	public function fill($array) {
		$this->id=$array['id'];
	}

}

?>
